package View;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import Controller.Sistema;
import Model.ClienteView;
import Model.LineaView;
import Model.RegistroConsumoView;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ConsumoCliente extends javax.swing.JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JLabel lblCantidadVoz;
	private JButton btnCerrar;
	private JLabel lblCantidadKb;
	private JLabel lblCantidadSms;
	private JFrame consumoCliente;
	private RegistroConsumoView registroConsumoView;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				ConsumoCliente inst = new ConsumoCliente();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public ConsumoCliente() {
		super();
		consumoCliente = this;
		initGUI();
	}
	
	public ConsumoCliente(ClienteView clienteSeleccionado, LineaView lineaSeleccionada) {
		super();
		this.consumoCliente = this;		
		registroConsumoView = Sistema.getInstancia().obtenerRegistroConsumo(clienteSeleccionado.getDni(), lineaSeleccionada.getNroLinea());
		initGUI();
		lblCantidadVoz.setText("Minutos de voz consumidos: " + registroConsumoView.getCantidadVoz());
		lblCantidadSms.setText("Cantidad de SMS utilizados: " + registroConsumoView.getCantidadSms());
		lblCantidadKb.setText("Cantidad de KB navegados: " + registroConsumoView.getCantidadDatos());
	}
	
	private void initGUI() {		
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				lblCantidadVoz = new JLabel();
				getContentPane().add(lblCantidadVoz);
				lblCantidadVoz.setText("Minutos de voz consumidos:");
				lblCantidadVoz.setBounds(12, 12, 360, 16);
			}
			{
				lblCantidadSms = new JLabel();
				getContentPane().add(lblCantidadSms);
				lblCantidadSms.setText("Cantidad de SMS utilizados:");
				lblCantidadSms.setBounds(12, 40, 360, 16);
			}
			{
				lblCantidadKb = new JLabel();
				getContentPane().add(lblCantidadKb);
				lblCantidadKb.setText("Cantidad de KB navegados:");
				lblCantidadKb.setBounds(12, 68, 360, 16);
			}
			{
				btnCerrar = new JButton();
				getContentPane().add(btnCerrar);
				btnCerrar.setText("Cerrar");
				btnCerrar.setBounds(259, 96, 101, 23);
				btnCerrar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						consumoCliente.dispose();
					}
				});
			}
			pack();
			this.setSize(400, 169);
			if(registroConsumoView.sinConsumo()){
				JOptionPane.showMessageDialog(this, "El cliente seleccionado no posee consumos registrados a la fecha");
				consumoCliente.dispose();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
